<extend name="Public/base"/>
<block name="style">	
	<style>
/* 拖动排序列表 */
.dragsort {

}
.edit_sort {
    display: inline-block;
    border:1px solid #cdcdcd;
    color: #404040;
    line-height: 35px;
    width: 20%;
    height: 376px;

}
.edit_sort span {
    background: #EEEEEE;
    width: 100%;
    display: inline-block;
    font-weight: bold;
    text-indent: 10px;
    border-bottom: 1px solid #cdcdcd;
    margin-bottom:5px;
}
.edit_sort ul {
    padding: 0 5px;
    overflow-y:scroll;
    height: 334px;
}
.edit_sort_l {
    float: left;
    margin-right: 20px;
}
.tab2 p {
    margin-bottom: 10px;
    font-weight: bold;
    text-indent: 15px;
}
.dragsort li {
    margin-bottom: 5px;
    padding: 0 6px;
    height: 30px;
    line-height: 30px;
    border: 1px solid #eee;
    background-color: #fff;
	overflow: hidden;
}
.dragsort li em {
    font-style: normal;
}
.dragsort li b {
    display: none;
    float: right;
    padding: 0 6px;
    font-weight: bold;
    color: #000;
}
.dragsort li:hover b {
    display: block;
}
.dragsort .draging-place {
    border-style: dashed;
    border-color: #ccc;
}
</style>
</block>
<block name="content">
<h3>模型</h3>
<div class="panel panel-default">
	<div class="panel-heading">
		<div class="panel-heading">
			<if condition="ACTION_NAME eq 'add'">新增<else/>编辑</if>模型
		</div>		
	</div>
 	<div class="panel-body">
 		<form id="form" action="<{:U('update')}>" method="post" class="form-horizontal doc-modal-form">	
			<ul class="nav nav-pills">
				<li class="active"><a href="#tab1" data-toggle="tab">基 础</a></li>
				<li><a href="#tab2" data-toggle="tab">设 计</a></li>
				<li><a href="#tab3" data-toggle="tab">高 级</a></li>
			</ul>		
			<!-- 表单 -->
			<div class="tab-content">						
				<!-- 基础 -->
				<div id="tab1" class="tab-pane fade in active">
					<div class="form-group">
						<label class="col-sm-2 control-label">模型标识</label>
						<div class="col-sm-2 ">
							<input type="text" class="form-control" name="name" value="<{$info.name}>">
						</div>
						<span class="help-block">请输入文档模型标识</span>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">模型名称</label>
						<div class="col-sm-2">
							<input type="text" class="form-control" name="title" value="<{$info.title}>">
						</div>
						<span class="help-block">请输入模型的名称</span>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">模型类型</label>
						<div class="col-sm-2 ">
							<select name="extend" class="form-control" style="width:auto">
								<option value="0">独立模型</option>
								<option value="1">文档模型</option>
							</select>
						</div>
						<span class="help-block">目前支持独立模型和文档模型</span>
					</div>
				</div>

				<div id="tab2" class="tab-pane fade">
					<div class="form-group">
						<label class="col-sm-2 control-label">字段管理</label>
							<div class=" cf edit_sort edit_sort_l form_field_sort">
								<span>字段列表 		[ <a href="<{:U('Attribute/add?model_id='.$info['id'])}>" target="_balnk">新增</a>
								<a href="<{:U('Attribute/index?model_id='.$info['id'])}>" target="_balnk">管理</a> ] </span>
								<ul class="dragsort">
									<foreach name="fields" item="field" key="k">
										<li >
											<em ><{$field['title']}> [<{$field['name']}>]</em>
										</li>
									</foreach>
								</ul>
							</div>
						<span class="help-block">只有新增了字段，该表才会真正建立</span>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">表单显示分组</label>
						<div class="col-sm-3">
							<input type="text" class="form-control" name="field_group" value="<{$info.field_group}>">
						</div>
						<span class="help-block">用于表单显示的分组，以及设置该模型表单排序的显示</span>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">表单显示排序</label>
						<volist name=":parse_field_attr($info['field_group'])" id="vo">
						<div class="form-item cf edit_sort edit_sort_l form_field_sort">
							<span><{$vo}></span>
							<ul class="dragsort needdragsort" data-group="<{$key}>">
								<foreach name="fields" item="field" key="k">
									<if condition="(($field['group'] eq $key) or($i eq 1 and !isset($field['group']))) and ($field['is_show'] eq 1)">
										<li class="getSort">
											<em data="<{$field['id']}>"><{$field['title']}> [<{$field['name']}>]</em>
											<input type="hidden" name="field_sort[<{$key}>][]" value="<{$field['id']}>"/>
										</li>
									</if>
								</foreach>
							</ul>
						</div>
						</volist>
						<span class="help-block">直接拖动进行排序</span>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label">列表定义</label>
						<div class="col-sm-2">
							<textarea name="list_grid" class="form-control"><{$info.list_grid}></textarea>
						</div>
						<span class="help-block">默认列表模板的展示规则</span>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label">默认搜索字段</label>
						<div class="col-sm-2">
							<input type="text" class="form-control" name="search_key" value="<{$info.search_key}>">
						</div>
						<span class="help-block">默认列表模板的默认搜索项</span>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">高级搜索字段</label>
						<div class="col-sm-2 ">
							<input type="text" class="form-control" name="search_list" value="<{$info.search_list}>">
						</div>
						<span class="help-block">默认列表模板的高级搜索项</span>
					</div>
				</div>

				<!-- 高级 -->
				<div id="tab3" class="tab-pane fade">
					<div class="form-group">
						<label class="col-sm-2 control-label">列表模板</label>
						<div class="col-sm-2 ">
							<input type="text" class="form-control" name="template_list" value="<{$info.template_list}>">
						</div>
						<span class="help-block">自定义的列表模板，放在Application\Admin\View\Think下，不写则使用默认模板</span>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">新增模板</label>
						<div class="col-sm-2 ">
							<input type="text" class="form-control" name="template_add" value="<{$info.template_add}>">
						</div>
						<span class="help-block">自定义的新增模板，放在Application\Admin\View\Think下，不写则使用默认模板/span>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">编辑模板</label>
						<div class="col-sm-2 ">
							<input type="text" class="form-control" name="template_edit" value="<{$info.template_edit}>">
						</div>
						<span class="help-block">自定义的编辑模板，放在Application\Admin\View\Think下，不写则使用默认模板</span>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label"></label>
						<div class="col-sm-2 ">
							<input type="text" class="form-control" name="list_row" value="<{$info.list_row}>">
						</div>
						<span class="help-block">默认列表模板的分页属性</span>
					</div>
				</div>
			</div>	
				
			<!-- 按钮 -->
			<div class="form-item cf">
				<label class="item-label"></label>
				<div class="controls edit_sort_btn">
					<input type="hidden" name="id" value="<{$info['id']}>"/>
					<button class="btn submit-btn ajax-post no-refresh" type="submit" target-form="form-horizontal">确 定</button>
					<button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
				</div>
			</div>				
				
		</form>
	</div>
</div>
</block>
<block name="script">
<script type="text/javascript" src="__STATIC__/jquery.dragsort-0.5.1.min.js"></script>
<script type="text/javascript" charset="utf-8">
//Think.setValue("extend", {$info.extend|default=0});

//导航高亮
//highlight_subnav('{:U('Model/index')}');

/*$(function(){
	showTab();
})*/
//拖曳插件初始化
$(function(){
	$(".needdragsort").dragsort({
	     dragSelector:'li',
	     placeHolderTemplate: '<li class="draging-place">&nbsp;</li>',
	     dragBetween:true,	//允许拖动到任意地方
	     dragEnd:function(){
	    	 var self = $(this);
	    	 self.find('input').attr('name', 'field_sort[' + self.closest('ul').data('group') + '][]');
	     }
	 });
})
</script>
</block>

